using System;
using System.Collections;
using System.Collections.Generic;




namespace SmallStepSemanticCsharp
{
    class Add : Exp
    {
        Exp left;
        Exp right;
       public Add(Exp left, Exp right)
        {
            this.left = left;
            this.right = right;
        }
        public override bool reducible()
        {
            return true;
        }
        public override Exp reduce(Dictionary<string,int> env)
        {
            if (left.reducible()){
                return new Add(left.reduce(env), right);
            }
            else if(right.reducible()){
                return new Add(left,right.reduce(env));
            } 
            else{
                return new Num(left.Val + right.Val);
            }

        }
        public override string ToString()
        {
            return $"{left}+{right}" ;
        }
    }

}

